/*
 *  Copyright 2009 David Kuhn <david.s.kuhn at gmail.com>.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package com.google.code.teamtools.domain;

import java.util.List;

/**
 * Interface for a resource owner. A resource may only have a single owner.
 * Joint ownership is not permitted for now.
 * 
 * @author David Kuhn
 */
public interface IResourceOwner
{
    /**
     * Returns a list of all the resources owned.
     * 
     * @return list of resources
     */
    List<IResource> getOwnedResources();

    /**
     * Returns <code>true</code> if <code>IResource</code> is owned by this
     * <code>IResourceOwner</code>.
     * 
     * @param resource
     * @return <code>true</code> if resource is owned, otherwise
     *         <code>false</code>.
     */
    boolean isOwnerOf(IResource resource);

    /**
     * Give up ownership of the specified resource. If the resource passed is
     * not owned by this resource owner then the operation has no effect.
     * 
     * @param resource the resource to relinquish ownership of
     */
    void relinquishOwnership(IResource resource);

    /**
     * Give up ownership of a group of resources. If the resources passed are
     * not owned by this resource owner then the operation has no effect.
     * 
     * @param resource a list of resources to relinquish ownership of
     */
    void relinquishOwnership(List<IResource> resource);

    /**
     * Take ownership of the given resource. This operation causes the prior
     * owner to relinquish control of the resource.
     * 
     * @param resource the resource to take ownership of
     */
    void takeOwnership(IResource resource);

    /**
     * Take ownership of a group of resources. This operation causes the prior
     * owner to relinquish control of the resource.
     * 
     * @param resources a list of resources to take ownership of
     */
    void takeOwnership(List<IResource> resources);
}
